package com.changan.controller;

import com.changan.model.Product;
import com.changan.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @program: alipay
 * @description: 商品控制器
 * @author: Mr.Nie
 * @create: 2021-12-10 11:26
 **/
@Controller
public class ProductController {

    @Autowired
    private ProductService productService;

    @RequestMapping("/product")
    public String toProduct(Model model){
        List<Product> productList = productService.getProducts();
        model.addAttribute("productList",productList);
        return "product";
    }

    @RequestMapping("/orderConfirm")
    public String orderConfirm(String id , Model model){
        Product product = productService.getProductById(id);
        model.addAttribute("product",product);
        return "orderConfirm";
    }
}
